//
//  NSDateFormatter+HBExtension.m
//  HBActionSheet
//
//  Created by 韩冰 on 2017/10/25.
//  Copyright © 2017年 韩冰. All rights reserved.
//

#import "NSDateFormatter+HBExtension.h"

@implementation NSDateFormatter (HBExtension)

+ (NSString *)getDateStrDate:(NSDate *)date dateFormatter:(NSString *)formatter
{
    NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
    NSDateFormatter *dateFormatter = threadDictionary[@"mydateFormatter"];
    if (!dateFormatter) {
        @synchronized(self)
        {
            if (!dateFormatter) {
                dateFormatter = [[NSDateFormatter alloc] init];
                [dateFormatter setLocale:[NSLocale currentLocale]];
                [dateFormatter setTimeZone:nil];
                threadDictionary[@"mydateFormatter"] = dateFormatter;
            }
        }
    }
    
    [dateFormatter setDateFormat:formatter];
    NSString *coversationDateString = [dateFormatter stringFromDate:date];
    return coversationDateString;
}

@end
